﻿
@{
    ViewBag.Title = "KaoHe";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="row" id="app">
    <div class="col-lg-12">
        <!--人员列表-->
        <div class="row" id="renyuanlist">
            <div class="col-xs-12">
                <div class="table-header">
                    教职工列表
                </div>
                <div>
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                            <tr>
                                <th class="center">
                                    账号/编号
                                </th>
                                <th>姓名</th>
                                <th>性别</th>
                                <th>所在科室</th>
                                <th>职务</th>
                                <th></th>
                            </tr>
                        </thead>

                        <tbody>
                            <tr v-for="tr in users">
                                <td class="center">
                                    {{tr.username}}
                                </td>
                                <td>{{tr.XingMing}}</td>
                                <td>
                                    <template v-if="tr.XingBie==0">
                                        未知
                                    </template>
                                    <template v-if="tr.XingBie==1">
                                        男
                                    </template>
                                    <template v-if="tr.XingBie==2">
                                        女
                                    </template>
                                </td>
                                <td>{{tr.ksmc}}</td>
                                <td>{{tr.zwmc}}</td>
                                <td>
                                    <div class="btn-group">
                                        <button data-toggle="dropdown" class="btn btn-primary btn-white dropdown-toggle btn-sm " aria-expanded="true">
                                            操作
                                            <i class="ace-icon fa fa-angle-down icon-on-right"></i>
                                        </button>
                                        <ul class="dropdown-menu">
                                            <li>
                                                <a href="javascript:void(0)" v-on:click="ShowKaoHeBiaos(tr.username,tr)">选择</a>
                                            </li>
                                        </ul>
                                    </div>
                                </td>
                            </tr>

                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!--工作计划详细信息-->
        <div class="row" id="gongzuojihuainfo" style="display: none">
            <div class="col-xs-12  widget-container-col">
                <!-- #section:custom/widget-box -->
                <div class="widget-box">
                    <div class="widget-header">
                        <h5 class="widget-title">编辑区</h5>

                        <!-- #section:custom/widget-box.toolbar -->
                        <div class="widget-toolbar">
                            <div class="widget-menu">
                                <a href="#" data-action="settings" data-toggle="dropdown">
                                    <i class="ace-icon fa fa-bars"></i>
                                </a>

                                <ul class="dropdown-menu dropdown-menu-right dropdown-light-blue dropdown-caret dropdown-closer">
                                    <li>
                                        <a data-toggle="tab" href="#dropdown1" v-on:click="ShowList()">返回列表</a>
                                    </li>

                                </ul>
                            </div>


                        </div>

                        <!-- /section:custom/widget-box.toolbar -->
                    </div>

                    <div class="widget-body">
                        <div class="widget-main">
                            <div class="form-horizontal" role="form">
                                <div class="row">
                                    <div class="col-xs-5">
                                        <div class="input-group">
                                            <span class="input-group-addon">
                                                工作计划名称：
                                            </span>
                                            <input type="text" class="form-control search-query" placeholder="工作计划名称" readonly="readonly" v-bind:value="userinfo.XingMing+'_'+khbinfo.mkhbmc" />

                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <template v-for="tr in khbinfo.MyKaoHeBiaoOnes">
                                        <table class="table  table-bordered table-hover">
                                            <thead class="thin-border-bottom">
                                                <tr>
                                                    <th>
                                                        名称
                                                    </th>
                                                    <th>分值</th>
                                                </tr>
                                            </thead>

                                            <tbody>

                                                <tr>
                                                    <td>
                                                        {{tr.mbnr}}
                                                    </td>

                                                    <td>
                                                        {{tr.fz}}
                                                    </td>
                                                </tr>
                                                <tr class="detail-row open">
                                                    <td colspan="2">
                                                        <div class="table-detail">
                                                            <div class="row">
                                                                <div class="col-xs-12">

                                                                    <table class="table table-striped table-bordered table-hover no-margin-bottom no-border-top">
                                                                        <thead>
                                                                            <tr>
                                                                                <th style="width: 300px">工作计划</th>
                                                                                <th style="width: 150px">预计完成时间</th>
                                                                                <th>工作承担人</th>
                                                                                <th style="width: 300px">工作完成情况(佐证材料)</th>

                                                                                <th>分值</th>
                                                                                @*<th>自评</th>*@
                                                                                <th>评分</th>
                                                                            </tr>
                                                                        </thead>
                                                                        <tbody>
                                                                            <tr v-for="(son,indexson) in tr.MyKaoHeBiaoTwos">
                                                                                <td>
                                                                                    {{son.mbnr}}
                                                                                </td>
                                                                                <td>
                                                                                    {{son.gzjhwcsj}}
                                                                                </td>
                                                                                <td>
                                                                                    {{son.gzcdr}}
                                                                                </td>
                                                                                <td>
                                                                                    <template v-if="son.MyKaoHeBiaotwoFuJianses.length>
                                                                                            0">
                                                                                        <a href="javascript:void(0)" v-on:click="showfujian(son.twoid)">{{son.gzjhwcqk}}</a>
                                                                                    </template>
                                                                                    <template v-if="son.MyKaoHeBiaotwoFuJianses.length==
                                                                                            0">
                                                                                        {{son.gzjhwcqk}}
                                                                                    </template>
                                                                                </td>

                                                                                <td>
                                                                                    <div class="input-group">
                                                                                        {{son.fz}}
                                                                                    </div>
                                                                                </td>
                                                                                @*<td>
                                                                                    {{son.zp}}
                                                                                </td>*@
                                                                                <td>
                                                                                    <table>
                                                                                        <tr v-for="(pa,paindex) in son.PersonalAnswers">
                                                                                            <td>
                                                                                                <template v-if="son.PersonalAnswers.length>1">
                                                                                                    {{pa.tips}}
                                                                                                </template>
                                                                                            </td>
                                                                                            <td v-html="decodeURI(pa.html)"></td>
                                                                                        </tr>
                                                                                    </table>

                                                                                </td>
                                                                            </tr>
                                                                        </tbody>
                                                                    </table>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </td>
                                                </tr>

                                            </tbody>
                                        </table>
                                    </template>
                                </div>
                                <div class="clearfix form-actions">
                                    <div class="col-md-offset-1 col-md-11">
                                        <button class="btn btn-white btn-info btn-bold" type="button" v-on:click="save()">
                                            <i class="ace-icon fa fa-floppy-o bigger-120 blue"></i>
                                            保存
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- /section:custom/widget-box -->
            </div>

            <!-- /.span -->
        </div>
        <!--弹出框-->
        <div class="row">
            <div class="col-xs-12">
                <div id="dialog-linshigongzuo" class="hide">
                    <div class="row">
                        <div class="col-xs-12">
                            <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <th class="center">
                                            附件
                                        </th>
                                        <th>标题</th>
                                    </tr>
                                </thead>

                                <tbody>
                                    <tr v-for="tr in uploaderfiles">
                                        <td class="center">
                                            <a v-bind:href="tr.path" target="_blank"><img width="50" height="50" v-bind:src="tr.path" /></a>
                                        </td>
                                        <td>{{tr.fjmc}}</td>

                                    </tr>
                                </tbody>
                            </table>
                        </div><!-- /.span -->
                    </div><!-- /.row -->
                </div><!-- #dialog-message -->
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12">
                <div id="dialog-kaohebiaos" class="hide">
                    <div class="row">
                        <div class="col-xs-12">
                            <table class="table table-striped table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <th class="center">
                                            考核名
                                        </th>
                                        <th></th>
                                    </tr>
                                </thead>

                                <tbody>
                                    <tr v-for="tr in khblist">
                                        <td class="center">
                                            @*<a v-bind:href="tr.path" target="_blank">{{tr.mkhbmc}}</a>*@
                                            <a href="javascript:void(0)" v-on:click="ShowKaoHeBiaoInfo(tr)">{{tr.mkhbmc}}</a>
                                        </td>
                                        <td></td>

                                    </tr>
                                </tbody>
                            </table>
                        </div><!-- /.span -->
                    </div><!-- /.row -->
                </div><!-- #dialog-message -->
            </div>
        </div>
    </div>
</div>
<script src="~/Scripts/JsModel/Model_GongZuoJiHua.js"></script>
<script src="~/Scripts/JsModel/Model_KaoHeBiao.js"></script>
<script src="~/Scripts/JsModel/Model_JiaoZhiGong.js"></script>
<script type="text/javascript">
    var vm = new Vue(
        {
            el: "#app",
            data: {
                users: [],
                khbinfo: new KaoHeBiao(),
                gzjhdialog: {},
                khblist: [],
                uploaderfiles: [],
                userinfo: {},
                json:[]
            },
            mounted() {
                this.initPage();
            },
            methods: {
                initPage: function() {
                    var _self = this;
                    _self.p_Gets();
                    //$.showloading();
                },
                p_Gets: function() { //获取考核人员列表
                    var _self = this;
                    $.showloading();
                    axios.get("@Url.Action("GetKaoHeRenYuans", "Review")").then((response) => {
                            //$.closeloading();
                            _self.users = [];
                        for (var i = 0; i < response.data.length; i++) {
                                _self.users.push(response.data[i]);
                                //debugger;
                        }
                            $.closeloading();
                        },
                        (response) => {

                        }
                    ).catch(function(response) {
                        console.log(response);
                    });
                },
                p_GetKaoHeBiaos: function(username,obj) { //获取考核表详细
                    var _self = this;
                    _self.userinfo = obj;
                    $.showloading();
                    axios.get("@Url.Action("GetKaoHeBiaos", "Review")", { params: { username: username } }).then((response) => {
                            _self.khblist = [];
                        $(response.data).each(function (i, item) {
                            _self.khblist.push(item);
                        });
                        $.closeloading();
                        },
                        (response) => {

                        }
                    ).catch(function(response) {
                        console.log(response);
                    });
                },
                ShowKaoHeBiaos: function(username,obj) {
                    var _self = this;
                    _self.p_GetKaoHeBiaos(username, obj);
                    dialog_comm(false, "dialog-kaohebiaos", "查看附件", null, function () { }, true, 600);
                    //$("#renyuanlist").hide(function() {

                    //});
                    //_self.gzjhdialog.dialog("close");
                },
                ShowList: function () {
                    $("#gongzuojihuainfo").hide(function() {
                        $("#renyuanlist").show();
                    });
                },
                ShowKaoHeBiaoInfo(obj) {
                    var _self = this;
                    _self.khbinfo = obj;
                    $("#renyuanlist").hide(function () {
                        $("#gongzuojihuainfo").show();
                    });
                    $("#dialog-kaohebiaos").dialog("close");
                },
                //SelectItem: function (event) {
                //    debugger;
                //    event.preventDefault();
                //    let target = event.target;
                //    console.log($(target).parent.attr("data-index"));
                //    //document.getElementById('index').value = target.getAttribute("data-index");
                //},
                save() {
                    var _self = this;
                    var checkbox = $("input:checked");
                    _self.json = [];
                    $(checkbox).each(function(i, item) {
                        _self.json.push({ pcid: $(item).attr("name"), fz: $(item).val() });
                    });
                    var postdata = {
                        khbid: _self.khbinfo.mkhbid, data: _self.json}
                    $.showloading();
                    axios.post("@Url.Action("SavePingShenResult", "Review")", postdata).then((response) => {
                            $.closeloading();
                            if (response.data.error) {
                                bootbox.alert(response.data.data);
                            } else {
                                bootbox.alert("成功", function () {
                                    _self.p_Gets();
                                    _self.ShowList();
                                });
                            }


                        },
                        (response) => {
                            bootbox.alert("分值不合适，请重新核对");
                        }
                    ).catch(function(response) {
                        console.log(response);
                    });
                },
                AllItemPingFenClean: function () {
                    var _self = this;
                    $(_self.khbinfo.MyKaoHeBiaoOnes).each(function (i, item) {
                        $(item.MyKaoHeBiaoTwos).each(function(i2, item2) {
                            item2.MyKaoHeBiaoTwoPingFens = [];
                        });
                    });
                },
                SelectAllItem: function() {
                    var _self = this;
                    _self.AllItemPingFenClean();
                    $(_self.khbinfo.MyKaoHeBiaoOnes).each(function (i, item) {
                        var checkbox = $("[name=" + item.oneid + "]input:" + item.onetype + ":checked");
                        if (!checkbox || checkbox.length==0) {
                            checkbox = $("[name=" + item.oneid + "]input:text");
                        }
                        $(checkbox).each(function (i3, item3) {
                            item.MyKaoHeBiaoTwos[$(item3).closest("td").attr("data-index")].MyKaoHeBiaoTwoPingFens.push(
                                new MyKaoHeBiaoTwoPingFen({ fz: $(item3).val() }));
                        });
                    });
                    $.showloading();
                    axios.post("@Url.Action("SavePingShenResult", "Review")", _self.khbinfo).then((response) => {
                            $.closeloading();
                            if (response.data.error) {
                                bootbox.alert(response.data.data);
                            } else {
                                bootbox.alert("成功", function () {
                                    _self.p_Gets();
                                    _self.ShowList();
                                });
                        }


                        },
                        (response) => {
                            bootbox.alert("分值不合适，请重新核对");
                        }
                    ).catch(function(response) {
                        console.log(response);
                    });
                },
                showfujian: function (twoid) {
                    var _self = this;
                    var dialog = dialog_comm(false, "dialog-linshigongzuo", "查看附件", null, function () { }, true,600);
                    _self.GetFileList(_self.khbinfo.mkhbid, twoid);
                    e.preventDefault();
                },
                GetFileList: function (mkhbid, twoid) {
                    var _self = this;
                    $.showloading();
                    axios.get("@Url.Action("GetFileList", "MyCaoZuo")", { params: { mkhbid: mkhbid, twoid: twoid } })
                        .then((response) => {
                                _self.uploaderfiles = [];
                                for (var i = 0; i < response.data.length; i++) {
                                    _self.uploaderfiles.push(new MyKaoHeBiaoTwoFuJian(response.data[i]));
                            }
                                $.closeloading();
                            },
                            (response) => {

                            }
                        ).catch(function(response) {
                            console.log(response);
                        });
                }
            }
        });
</script>